package client;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import provider.WSProvider;

import com.cdyne.ws.weatherws.*;
import MashupModel.*;

public class SampleClient {
	public static void main(String args[]) throws MalformedURLException {
		URL url = new URL("http://localhost:9990/services?wsdl");
		QName qname = new QName("http://provider/", "WSProviderImplService");
		
		Service service = Service.create(url, qname);
		WSProvider provider = service.getPort(WSProvider.class);
		
		CityAirportInformationAndForecastModel cityAirportInformationAndForecastModel = provider.getAirportInfoAndForecastByZip("95112");
		List<Table> airportsInfo = cityAirportInformationAndForecastModel.getAirportsInfo();
		ForecastReturn forecastReturn = cityAirportInformationAndForecastModel.getForecastReturn();
		ArrayOfForecast arrayOfForecast = forecastReturn.getForecastResult();
		List<Forecast> forecastList = arrayOfForecast.getForecast();
		for (Table t : airportsInfo) {
			System.out.println("Airport Name: " + t.getCityOrAirportName());
			for (Forecast f : forecastList) {
				System.out.println("Weather Forecast Info: " + f.getDate() + " " + f.getDesciption());
			}
			System.out.println();
		}
		
	}

}
